const fs = require('fs');

// 读取txt文件
fs.readFile('input.txt', 'utf8', (err, data) => {
  if (err) throw err;

  // 将文本按行分割成数组
  const lines = data.trim().split('\n');

  // 创建新的数组
  const originalArray = lines.map(line => line.trim().split('\t'));

  // 提取第一列和第二列数据
  const column1 = originalArray.map(item => item[0]);
  const column2 = originalArray.map(item => item[1]);

  // 将新的数组转换成字符串
  const output1 = JSON.stringify(column1);
  const output2 = JSON.stringify(column2);

  // 写入新的txt文件
  fs.writeFile('output1.txt', output1, err => {
    if (err) throw err;
    console.log('Output1.txt has been saved!');
  });

  fs.writeFile('output2.txt', output2, err => {
    if (err) throw err;
    console.log('Output2.txt has been saved!');
  });
});
